writing binary files in python